﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ARS.Control.Custom.Entity.Fields;

namespace NetWebControl.ControlTest
{
     class Users_Roles
    {
        public Users_Roles()
        { }
        #region Model
        private int _users_roles_id;
        private int? _parentid;
        private string _name;
        private DateTime? _addtime;
        private string _remark;
        private int? _company_info_id;
        /// <summary>
        /// 角色ID
        /// </summary>
        [KeyField()]
        public int Users_Roles_Id
        {
            set { _users_roles_id = value; }
            get { return _users_roles_id; }
        }
        /// <summary>
        /// 父级角色ID
        /// </summary>
        //[ChoicesField(Verbose_Name = "性别",Choices="0|男,1|女",IsShow=true)]
        //[ForeignKeyConfig(TableName = "Users", DataTextField = "RealName", KeyField = "Users_Id")]
        //[ForeignKeyField(Verbose_Name = "选择", IsShow = true)]
        //public int? ParentId
        //{
        //    set { _parentid = value; }
        //    get { return _parentid; }
        //}
        /// <summary>
        /// 角色名字
        /// </summary>
        [CharField(Verbose_Name = "角色名字", IsAllowBlank = false,IsShow=true)]
        public string Name
        {
            set { _name = value; }
            get { return _name; }
        }
        [CharField(Verbose_Name = "角色名字", IsAllowBlank = false, IsShow = true)]
        public string Name1 { get; set; }
        [CharField(Verbose_Name = "角色名字", IsAllowBlank = false, IsShow = true)]
        public string Name2 { get; set; }
        [CharField(Verbose_Name = "角色名字", IsAllowBlank = false, IsShow = true)]
        public string Name3 { get; set; }
        public string Name11 { get; set; }
        [CharField(Verbose_Name = "角色名字", IsAllowBlank = false, IsShow = true)]
        public string Name22 { get; set; }
        [CharField(Verbose_Name = "角色名字", IsAllowBlank = false, IsShow = true)]
        public string Name33 { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [CharField(IsShow = true, Verbose_Name = "创建时间")]
        public DateTime? AddTime
        {
            set { _addtime = value; }
            get { return _addtime; }
        }
        /// <summary>
        /// 角色说明
        /// </summary>
        [ImageUploadField(Verbose_Name = "说明")]
        public string Remark
        {
            set { _remark = value; }
            get { return _remark; }
        }
        /// <summary>
        /// 公司ID
        /// </summary>
        [UserField()]
        public int? Company_Info_Id
        {
            set { _company_info_id = value; }
            get { return _company_info_id; }
        }
        #endregion Model

    }

    public partial class addoatest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Users_Roles role = new Users_Roles();
            this.EntityModifyPanel1.RequestKey = "Id";
            this.EntityModifyPanel1.Entity = role;

            this.EntityModifyPanel1.IsEncryptKey = false;

            this.EntityModifyPanel1.ColumnNumber = 3;

//            this.EntityModifyPanel1.EntityTableInfo.KeyInfo.Key = "ParentId";
//            this.EntityModifyPanel1.EntityTableInfo.KeyInfo.Value = 2;

            ARS.Control.Config.SetEntityModifyPanel.SetTrHtml("<th>{0}</th><td>{{0}}{1}</td>");//"<tr><td  class=\"reg_text\">{0}</td><td>


            this.EntityModifyPanel1.AddEntityToDbEvent += (control) =>
            {
                //Response.Write(control.Value);
                return null;
            };
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            this.EntityModifyPanel1.AddOrUpdateEntityToDb();

            //ARS.DataBase.MySqlProvider
        }
    }
}